package cn.blogsx.datasource.druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/*
druid 演示
 */
public class DruidDemo01 {
    public static void main(String[] args) throws Exception {
        //1、导报
        //2、定义配置文件
        //3、获取连接池对象
        //3.1
        Properties pro = new Properties();
        InputStream resourceAsStream = DruidDemo01.class.getClassLoader().getResourceAsStream("druid.properties");
        pro.load(resourceAsStream);
        DataSource dataSource = DruidDataSourceFactory.createDataSource(pro);
        //获取连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

    }
}
